package Ctr;

import java.util.ArrayList;

import DB.DBSupplier;
import Gui.Terminal;
import Model.Supplier;

/**
 * 
 * @author Patrick
 *
 */

public class CtrSupplier {
	public CtrSupplier()
	{
		
	}
	public ArrayList<Supplier> findAllSuppliers()
	{
		DBSupplier supp = new DBSupplier();
		ArrayList<Supplier> allSupp = new ArrayList<Supplier>();
		allSupp = supp.getAllSuppliers();
		return allSupp;
	}
	public Supplier findSupplier(String ID)
	{
		DBSupplier supp = new DBSupplier();
		return supp.getSupplier(ID);
	}
	public void updateSupplier(String ID, String Name, String Address, String Country, String PhoneNum, String Email)
	{
		DBSupplier supp = new DBSupplier();
		supp.updateSupplier(ID, Name, Address, Country, PhoneNum, Email);	
	}
	public void createSupplier(String Name, String Address, String Country, String PhoneNum, String Email)
	{
		DBSupplier supp = new DBSupplier();
		int i = Integer.parseInt(supp.getHighestNo()) + 1;
		String HighNo = Integer.toString(i);
		Supplier sup = new Supplier(HighNo, Name, Address, Country, PhoneNum, Email);
		try{
			supp.createSupplier(sup);
		}
		catch(Exception exception)
		{
			Terminal.say("Employee not Added");
		}
	}
	public void deleteSupplier(String ID)
	{
		DBSupplier supp = new DBSupplier();
		supp.deleteSupplier(ID);
	}
}
